package lab02.test32;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by dell on 2017/11/9.
 */
public class Test32 {

    public static void main(String[] args) {

        Map<String,String> map=new HashMap<>();

        //向map中添加数据
        map.put("id","1");
        map.put("name","张三");
        map.put("gender","男");
        map.put("age","25");
        map.put("love","爱学java");

        //如何遍历一个map
        for (Map.Entry<String,String> entry:map.entrySet()){

            System.out.println(entry.getKey());
            System.out.println(entry.getValue());

        }
        System.out.println("集合的大小："+map.size());

        //删除集合中key为age的元素
        for (Map.Entry<String,String> entry:map.entrySet()){

            if(entry.getKey().equals("age"));

            map.remove(entry.getKey());


        }
        System.out.println("集合的大小："+map.size());
    }


}
